package org.xingyun.web;

import org.xingyun.service.CityService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(value = "/city", name = "cityServlet")
public class CityServlet extends javax.servlet.http.HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            System.out.println("查询城市的请求来了");
            response.setContentType("text/json;charset=utf-8");
            String provinceid = request.getParameter("provinceid");
            System.out.println(provinceid);
            String allCity = new CityService().getAllCity(provinceid);
            response.getWriter().write(allCity);
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
